home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume9 / tttt / patch1 < prev   
Encoding:
Text File  |  1990-03-17  |  5.8 KB  |  248 lines

  1. Path: uunet!zephyr.ens.tek.com!tekred!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v09i034:  tttt - tic-tac-toc-toe with wraparound edges, Patch1
  5. Message-ID: <5296@tekred.CNA.TEK.COM>
  6. Date: 9 Mar 90 23:40:28 GMT
  7. Sender: news@tekred.CNA.TEK.COM
  8. Lines: 237
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: Eric Lechner <lechner@ucscb.ucsc.edu>
  12. Posting-number: Volume 9, Issue 34
  13. Archive-name: tttt/Patch1
  14. Patch-To: tttt: Volume 9, Issue 33
  15.  
  16.     [Copied from comp.sources.games.bugs so it will get archived.
  17.      if you already applied this patch, don't do it again.  -br]
  18.  
  19. [[This patch for "tttt" allows the player to scroll the tic-tac-toc-toe
  20. board around, so that "wraparound" wins are easier to spot.
  21.  
  22. It also includes a more graceful exit from a control-c exit, and
  23. a "make shar" option in the Makefile.
  24.  
  25. -Eric Lechner, 7 March 1990]]
  26.  
  27. #! /bin/sh
  28. # This is a shell archive.  Remove anything before this line, then unpack
  29. # it by saving it into a file and typing "sh file".  To overwrite existing
  30. # files, type "sh file -c".  You can also feed this as standard input via
  31. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  32. # will see the following message at the end:
  33. #        "End of shell archive."
  34. # Contents:  patches01
  35. # Wrapped by billr@saab on Fri Mar  9 15:40:34 1990
  36. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  37. if test -f 'patches01' -a "${1}" != "-c" ; then 
  38.   echo shar: Will not clobber existing file \"'patches01'\"
  39. else
  40. echo shar: Extracting \"'patches01'\" \(3977 characters\)
  41. sed "s/^X//" >'patches01' <<'END_OF_FILE'
  42. Xdiff -c ../tttt.old/Makefile ./Makefile
  43. X*** ../tttt.old/Makefile    Thu Mar  8 11:05:41 1990
  44. X--- ./Makefile    Thu Mar  8 10:35:16 1990
  45. X***************
  46. X*** 27,30 ****
  47. X      nroff -man tttt.6 > tttt.man
  48. X  
  49. X  clean:
  50. X!     rm -f tttt *.o tttt.man
  51. X--- 27,33 ----
  52. X      nroff -man tttt.6 > tttt.man
  53. X  
  54. X  clean:
  55. X!     rm -f tttt *.o tttt.man tttt.shar
  56. X! 
  57. X! shar:
  58. X!     shar README Makefile tttt.6 tttt.c > tttt.shar
  59. Xdiff -c ../tttt.old/tttt.6 ./tttt.6
  60. X*** ../tttt.old/tttt.6    Thu Mar  8 11:05:44 1990
  61. X--- ./tttt.6    Thu Mar  8 10:21:15 1990
  62. X***************
  63. X*** 18,23 ****
  64. X--- 18,40 ----
  65. X  .PP
  66. X  The first player to connect four squares in a row wins.  If
  67. X  the board becomes filled without a winner, it is a tie game.
  68. X+ .SH COMMANDS
  69. X+ .RS
  70. X+ .IP "a-d, 0-4"
  71. X+ Select the row and column for your move.
  72. X+ .IP h
  73. X+ Scroll the board left.
  74. X+ .IP l
  75. X+ Scroll the board right.
  76. X+ .IP k
  77. X+ Scroll the board up.
  78. X+ .IP j
  79. X+ Scroll the board down.
  80. X+ .IP ctrl-L
  81. X+ Redraw the screen.
  82. X+ .IP q
  83. X+ Quit the game.
  84. X+ .RE
  85. X  .SH HISTORY
  86. X  This program was originally written for an Advanced Logic
  87. X  Design class, as a high level version of the program to
  88. Xdiff -c ../tttt.old/tttt.c ./tttt.c
  89. X*** ../tttt.old/tttt.c    Thu Mar  8 11:05:55 1990
  90. X--- ./tttt.c    Thu Mar  8 02:46:53 1990
  91. X***************
  92. X*** 14,19 ****
  93. X--- 14,20 ----
  94. X  
  95. X  #include <stdio.h>
  96. X  #include <curses.h>
  97. X+ #include <signal.h>
  98. X  
  99. X  #define EMPTY    0
  100. X  #define X    1
  101. X***************
  102. X*** 22,27 ****
  103. X--- 23,32 ----
  104. X  #define TIE    -1        /* for ending when the board is full */
  105. X  #define QUIT    -2
  106. X  
  107. X+ #define UP    1        /* definitions for board scrolling routine */
  108. X+ #define DOWN    2
  109. X+ #define LEFT    3
  110. X+ #define RIGHT    4
  111. X  #define WIN    100        /* for position rank scoring */
  112. X  
  113. X  #ifndef TRUE
  114. X***************
  115. X*** 32,44 ****
  116. X  char board [4][4];        /* this is the playing board */
  117. X  int pieces;
  118. X  
  119. X! void    initboard(),
  120. X!     printboard();
  121. X  
  122. X! int    check_win(),
  123. X!     getrank(),
  124. X      x_move(),        /* "our" move */
  125. X!     o_move();        /* the computer player's move */
  126. X  
  127. X  main()
  128. X  {
  129. X--- 37,51 ----
  130. X  char board [4][4];        /* this is the playing board */
  131. X  int pieces;
  132. X  
  133. X! void    initboard(),        /* initialize the board */
  134. X!     printboard(),        /* print the board */
  135. X!     shift();        /* board shifter */
  136. X  
  137. X! int    check_win(),        /* check for a win */
  138. X!     getrank(),        /* move ranking */
  139. X      x_move(),        /* "our" move */
  140. X!     o_move(),        /* the computer player's move */
  141. X!     quit();            /* control-c signal exit */
  142. X  
  143. X  main()
  144. X  {
  145. X***************
  146. X*** 52,57 ****
  147. X--- 59,66 ----
  148. X      cbreak();
  149. X      noecho();
  150. X  
  151. X+     signal(SIGINT,quit);
  152. X+ 
  153. X      initboard();
  154. X  
  155. X      clear();
  156. X***************
  157. X*** 168,173 ****
  158. X--- 177,202 ----
  159. X              case 'Q' :
  160. X                  return(QUIT);
  161. X                  break;
  162. X+             case 'j' :
  163. X+             case 'J' :
  164. X+                 shift(DOWN);
  165. X+                 printboard();
  166. X+                 goto GetX;
  167. X+             case 'k' :
  168. X+             case 'K' :
  169. X+                 shift(UP);
  170. X+                 printboard();
  171. X+                 goto GetX;
  172. X+             case 'l' :
  173. X+             case 'L' :
  174. X+                 shift(RIGHT);
  175. X+                 printboard();
  176. X+                 goto GetX;
  177. X+             case 'h' :
  178. X+             case 'H' :
  179. X+                 shift(LEFT);
  180. X+                 printboard();
  181. X+                 goto GetX;
  182. X              case 0x12 :
  183. X              case 0x0c :
  184. X                  clear();
  185. X***************
  186. X*** 347,349 ****
  187. X--- 376,427 ----
  188. X      return (0);
  189. X  }
  190. X  
  191. X+ /*
  192. X+     this is the board shifter.  it's so you can move the
  193. X+     board around to look at wraparound edges better...
  194. X+ */
  195. X+ void shift(type)
  196. X+ int type;
  197. X+ {
  198. X+     int i, j, tmp;
  199. X+ 
  200. X+     for (i=0; i<4; i++) {
  201. X+         switch (type) {
  202. X+             case UP:
  203. X+                 tmp = board[0][i];
  204. X+                 for (j=0; j<3; j++)
  205. X+                     board[j][i] = board[j+1][i];
  206. X+                 board[3][i] = tmp;
  207. X+                 break;
  208. X+             case DOWN:
  209. X+                 tmp = board[3][i];
  210. X+                 for (j=3; j>0; j--)
  211. X+                     board[j][i] = board[j-1][i];
  212. X+                 board[0][i] = tmp;
  213. X+                 break;
  214. X+             case LEFT:
  215. X+                 tmp = board[i][0];
  216. X+                 for (j=0; j<3; j++)
  217. X+                     board[i][j] = board[i][j+1];
  218. X+                 board[i][3] = tmp;
  219. X+                 break;
  220. X+             case RIGHT:
  221. X+                 tmp = board[i][3];
  222. X+                 for (j=3; j>0; j--)
  223. X+                     board[i][j] = board[i][j-1];
  224. X+                 board[i][0] = tmp;
  225. X+                 break;
  226. X+         }
  227. X+     }
  228. X+ }
  229. X+ 
  230. X+ int quit()
  231. X+ {
  232. X+     move(21,0);
  233. X+     refresh();
  234. X+     sleep(2);
  235. X+     resetty();
  236. X+     endwin();
  237. X+ 
  238. X+     exit(0);
  239. X+ }
  240. END_OF_FILE
  241. if test 3977 -ne `wc -c <'patches01'`; then
  242.     echo shar: \"'patches01'\" unpacked with wrong size!
  243. fi
  244. # end of 'patches01'
  245. fi
  246. echo shar: End of shell archive.
  247. exit 0
  248.